Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix greedy DB/DW string with [[:print:]] class #9

Merged
merged 1 commit into from
Mar 13, 2023
Merged

Fix greedy DB/DW string with [[:print:]] class #9

merged 1 commit into from
Mar 13, 2023

Conversation

FrancoisCapon
Copy link
Contributor

Hello,

We have the same issue with my students: #5 (comment)

I tried different classes on https://rustexp.lpil.uk/ and found that [[:print:]] is "not greedy".

So, the issue can be fixed by using [[:print:]] class in preprocessor.lalrpop for DB and DW.

Two strings 👌

byte01: DB 0x11
string01: DB "123"
string02: DW "456" 
byte02: DB 0x44

start:
print mem :7
MOV AX, 0x1111
MOV BL, OFFSET string01
MOV CL, OFFSET string02
MOV DX, 0x4444
print reg
$ emulator_8086 99-test.asm 
Syntax Error at 10:8 : MOV CL, OFFSET string02 :
Label string02 is not declared.

$ ./8086-Emulator/target/debug/emulator_8086 99-test.asm 
Output of line 7 : print mem :7 :
11	31	32	33	34	35	36	44		
Output of line 12 : print reg :
AX : 0x1111		SP : 0x0000
BX : 0x0001		BP : 0x0000
CX : 0x0004		SI : 0x0000
DX : 0x4444		DI : 0x0000

CS : 0xFFFF		SS : 0x0000
DS : 0x0000		ES : 0x0000

No regression 👌 (I hope 😉)

for p in ./8086-Emulator/examples/*.s
do
    echo $p
    if [ $1 == origin ]
    then
        emulator_8086 $p
    else # patched
        ./8086-Emulator/target/debug/emulator_8086 $p
    fi
done

$ ./all-test.sh origin > o.txt && ./all-test.sh patched > p.txt  && diff o.txt p.txt | wc 
      0       0       0

@FrancoisCapon
Copy link
Contributor Author

  • I found the unit tests: 👌
 cargo test --all --all-features --no-fail-fast
   Compiling emulator_8086 v0.1.0 (/home/ulyssa/labs/8086/DB-string/8086-Emulator)
    Finished test [unoptimized + debuginfo] target(s) in 9.65s
     Running unittests (target/debug/deps/emulator_8086_lib-2873deff1a139b46)

running 68 tests
test data_parser::data_parser_tests::test_db_string ... ok 👌
test data_parser::data_parser_tests::test_dw_number ... ok
test data_parser::data_parser_tests::test_dw_string ... ok 👌
test data_parser::data_parser_tests::test_set_directive ... ok
...
test preprocessor::preprocessor_tests::test_macro ... ok

test result: ok. 68 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.10s
  • I use my forked repository to build the web version: multiple DB/DW string are possible 👌
Cargo.toml
[dependencies]
wasm-bindgen = "0.2.63"
wee_alloc = { version = "0.4.5", optional = true }
lalrpop-util = "0.19.1"
regex = "1"
console_error_panic_hook = { version = "0.1.6", optional = true }
lib8086 = { git = "https://github.com/FrancoisCapon/YJDoc2--8086-Emulator", package="emulator_8086"}
#lib8086 = { git = "https://github.com/YJDoc2/8086-Emulator", package="emulator_8086"}

@YJDoc2
Copy link
Owner

YJDoc2 commented Feb 7, 2023

Hey @FrancoisCapon Thanks a lot for taking time to contribute. I'm currently busy, but I will try to check this and the other PR (on the web repo) as soon as I can.

Thanks again!

Copy link
Owner

@YJDoc2 YJDoc2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

Hey, took me long enough! Sorry 😅
Thanks a lot for fixing this 👍

@YJDoc2 YJDoc2 merged commit 33553dc into YJDoc2:master Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants